﻿using System;
using System.Collections.Generic;

using System.Text;

namespace DTO
{
    public class User : Person
    {
        #region Fields
        #endregion

        #region Properties
        public string Username { get; set; }
        public string Password { get; set; }
        public bool IsAdmin { get; set; }
        public string Passphrase { get; set; }
        public Customer Customer { get; set; }
        public RoleInfo Role { get; set; }
        public ServerRoleInfo ServerRole { get; set; }
        #endregion

        #region Constructors
        public User () : this(0) { }
        public User (int id) : base(id) { }        
        #endregion

        #region Private Methods
        #endregion

        #region Public Methods
        public override string ToString()
        {
            return base.ToString();
        }

        public static User Sample1()
        {
            return new User(1)
            {
                Username = "admin@xyz123",
                Password = "",
                FirstName = "Dave",
                LastName = "Bane",
                Email = "dave.bane@r-t-inc.com",
                Phone = "214-931-9534",
                Location = LocationInfo.Sample(),
                Role = RoleInfo.Sample(1),
                ServerRole = ServerRoleInfo.Sample(1)
            };
        }
        public static User Sample2 ()
        {
            return new User(2)
            {
                Username = "hnguyen@xtz222",
                Password = "",
                FirstName = "Peter",
                LastName = "Nguyen",
                Email = "peter.nguyen@mint-corp.com",
                Phone = "",
                Location = LocationInfo.Sample(),
                Role = RoleInfo.Sample(1),
                ServerRole = ServerRoleInfo.Sample(1)
            };
        }
        #endregion

        public class RoleInfo : BaseDTO
        {
            #region Fields
            #endregion

            #region Properties
            public string Name { get; set; }
            public string Description { get; set; }
            public bool IsAllow { get; set; }
            #endregion

            #region Constructors
            public RoleInfo () : this(0) { }
            public RoleInfo ( int id )
                : base(id)
            {
            }
            #endregion

            #region Private Methods
            #endregion

            #region Public Methods
            public static RoleInfo Sample(int index)
            {
                if (index == 1)
                    return new RoleInfo(index) { Name = "Administrator", Description = "Full access to everything." };

                return new RoleInfo(index) { Name = "Billing", Description = "Access to information, and perform billing functions only." };               
            }
            public static IList<RoleInfo> Samples ()
            {
                IList<RoleInfo> list = new List<RoleInfo>();
                list.Add(RoleInfo.Sample(1));
                list.Add(RoleInfo.Sample(2));
                return list;
            }
            #endregion
        }

        public class ServerRoleInfo : BaseDTO
        {
            #region Fields
            #endregion

            #region Properties
            public string Name { get; set; }
            public string Description { get; set; }
            public bool IsAllow { get; set; }
            #endregion

            #region Constructors
            public ServerRoleInfo () : this(0) { }
            public ServerRoleInfo ( int id )
                : base(id)
            {
            }
            #endregion

            #region Private Methods
            #endregion

            #region Public Methods
            public static ServerRoleInfo Sample(int index)
            {
                if (index == 1)
                    return new ServerRoleInfo(index) { Name = "Administrator", Description = "Login and manage any server." };

                return new ServerRoleInfo(index) { Name = "Remote Access", Description = "Login to servers as a non administrative user." };
            }
            public static IList<ServerRoleInfo> Samples ()
            {
                IList<ServerRoleInfo> list = new List<ServerRoleInfo>();
                list.Add(ServerRoleInfo.Sample(1));
                list.Add(ServerRoleInfo.Sample(2));
                return list;
            }
            #endregion
        }
    }
}
